using System.Collections.Generic;

namespace Intyme.Common.DataModel {
    /// <summary>
    /// Class define data and structure for One Operation
    /// </summary>  
    public class OperationClass {
        public int ID = -2;
        public string Name;
        public OperationType Type = OperationType.None;
        public double DefaultOperationTime;
        public List<LinkOperationToMachine> LinksToMachine;

        ///!!!!!!!!!!
        public int ParentComponentID = -2;

        public OperationClass() {
            ID = -1;
            Name = string.Empty;
            Type = OperationType.None;

            if (LinksToMachine == null) {
                LinksToMachine = new List<LinkOperationToMachine>();
            }

            ParentComponentID = -1;
        }

        ~OperationClass() {
            if (LinksToMachine != null) {
                LinksToMachine.Clear();
                LinksToMachine = null;
            }
        }

        public WorkstationType GetOperationTypeAsSolverIndex() {
            WorkstationType result = WorkstationType.None;

            switch (Type) {
                case OperationType.Casting:
                case OperationType.CastingPlastic:
                    result = WorkstationType.AluminiumCasting;
                    break;
                case OperationType.ManualCasting:
                    result = WorkstationType.ManualCasting;
                    break;
                case OperationType.CNC:
                case OperationType.Multipurpose:
                    result = WorkstationType.CNC;
                    break;
                case OperationType.Filing:
                case OperationType.Assembly:
                case OperationType.ComplicatedAssembly:
                    result = WorkstationType.Manual1;
                    break;
            }

            return result;
        }
    }
}